import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-22
 * Time: 10:12
 */
public class Deom26 {
    public static void main(String[] args) {
        //1.创建一个固定数目的线程
        ExecutorService service = Executors.newFixedThreadPool(10);
        for (int i = 0; i <50000 ; i++) {
            int id = i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello " + id + ", " + Thread.currentThread().getName());
                }
            });
            //2.根据任务的数量来自动进行线程扩容
            ExecutorService service1 = Executors.newCachedThreadPool();
            //3.创建一个固定线程个数，但是任务延时执行的线程池
            ExecutorService service2 = Executors.newScheduledThreadPool(4);
        }
    }
}
